<?php
// +----------------------------------------------------------------------
// | 软件版本管理模块 
// +----------------------------------------------------------------------
// | Author: 张坤
// +----------------------------------------------------------------------
namespace Admin\Controller; 
class SoftwareversionController extends AdminController { 
	/**
	 * 图片展示 
	 */
	public function index() {
		$list=M('Softwareversion')->select();
		int_to_string($list);
		$this->assign("_list",$list);
		$this->display('index');
	} 
	/**
	 * 保存图片
	 */
	public function save() { 
		$res = D('Softwareversion')->update();
		if(!$res){
			$this->error(D('Softwareversion')->getError());
		}else{
			$this->success('保存成功！', U('Softwareversion/index'));
		}
	}
	/**
	 * 删除
	 */
	public function delete($id) { 
		$map ['id'] = $id;
		M("Softwareversion")->where($map)->delete();		
		$this->success('操作成功',U('Softwareversion/index'),false);
	}
	/**
	 * 修改前显示
	 */
	public function edit($id) {
		//当前编辑页面 
		$data = M ( 'Softwareversion' )
				->field ( true )
				->find ( $id );
		$this->assign ( 'data', $data );
		//所有信息
		$list = M('Softwareversion')
				->select();
		$this->assign("_list",$list);
		$this->display('index');
	}
	public function changeStatusSingle($method=null,$id=null){
		$Softwareversion=D('Softwareversion');
		$data['id']=$id;
		switch (strtolower($method)){
			case 'forbid':
				$data['status']=0;
				break;
			case 'resume':
				$data['status']=1;
				break;
			default:
				$this->error('参数非法');
		}
		$Softwareversion->save($data);
		$this->success('操作成功',U('Softwareversion/index'),false);
	}
}
